package com.share.servlet;

import com.share.domain.BlogDomain;
import com.share.domain.BlogDomainImpl;
import com.share.entity.Blog;
import com.share.servlet.utils.ForwardUtils;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class IndexServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		BlogDomain blogDomain = new BlogDomainImpl();
		int page = 0;
		List<Blog> blogs = blogDomain.getBlogs(page);
		request.setAttribute("blogs", blogs);
		ForwardUtils.forward(request, response, "/blog/blog-list.jsp", getServletContext());
	}
}